package internal

import (
	"context"
	"log"

	"gitee.com/lyuanbo/stock-trade/internal/conf"
	"gitee.com/lyuanbo/stock-trade/internal/pkg/mq"
	"gitee.com/lyuanbo/stock-trade/internal/pkg/stock/constant"
	"gitee.com/lyuanbo/stock-trade/internal/pkg/stock/indicators"
	"gitee.com/lyuanbo/stock-trade/internal/pkg/stock/strategy"
	"gitee.com/lyuanbo/stock-trade/internal/pkg/stock/xueqiu"
	"github.com/maypok86/otter"
)

func Run() {
	// 配置
	config := conf.New()

	// 存储
	store, err := otter.MustBuilder[string, []*constant.Kline](1000000).Build()
	if err != nil {
		log.Fatal(err)
	}

	err = xueqiu.Run(context.Background(), xueqiu.WithToken(config.XueQiu.Token), xueqiu.WithStore(store), xueqiu.WithMq(mq.Default()))
	if err != nil {
		log.Fatal(err)
	}

	// 运行指标
	indicators.Run(store)

	// 运行策略
	strategy.Run()

}
